﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class goodsAdd_Productlist : System.Web.UI.Page, HZ.MBSM.BLL.IPageDescribe
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
            showGridView();
        }
    }

    protected void Button5_Click(object sender, EventArgs e)
    {
        

    }

/// <summary>
/// 将数据绑定到datalist
/// </summary>
    public void showGridView()
    {

        string strConditions = fctConditions();
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = "product";                                               //要查询的表明
        dbPage.Key = "productid";                                               //表的主键    
        dbPage.Where = strConditions;                                           //查询条件    
        dbPage.SelectField = "productid,productcode,productname,medicinemodel,outlookc,unit,xishu,zl,hl";//要显示的字段
        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);          //要显示第几页   
        dbPage.PageSize = 10;                                                    //没有显示记录条数   
        dbPage.OrderBy = "productcode,productname,medicinemodel,outlookc";                  //排序字段
        System.Data.IDataReader dr = dbPage.ExecuteReader();
        GridView1.DataSource = dr;
        GridView1.DataBind();
        dr.Close();
        dbPage.Db.Close();
        db.Close();
        dr = null;
        db = null;

        this.DbPageFlip1.DbPage = dbPage;//将数据传给控键



    }
    /// <summary>
    /// 生成查询条件
    /// </summary>
    /// <returns></returns>
    public string fctConditions()
    {
        string _strWhere = "";
        //品目号

        string _strProductCode = txtProductCode.Text.Trim();
        if (_strProductCode != "")
        {
            _strWhere = _strWhere + " Productid like '%" + _strProductCode + "%' and";
        }
        //通用名

        string _strProductName = txtProductName.Text.Trim();
        if (_strProductName != "")
        {
            _strWhere = _strWhere + " (ProductName like '%" + _strProductName + "%' or " + " SpellingCode like '%" + _strProductName + "%') and";
        }

        //剂型
        string _strMedicinemodel = txtMedicinemodel.Text.Trim();
        if (_strMedicinemodel != "")
        {
            _strWhere = _strWhere + " medicinemodel like '%" + _strMedicinemodel + "%' and";
        }

        //规格
        string _strOutlookc = txtOutlook.Text.Trim();
        if (_strOutlookc != "")
        {
            _strWhere = _strWhere + " outlookc like '%" + _strOutlookc + "%' and";
        }
        if (_strWhere != "")
        {
            _strWhere = "  " + _strWhere.Substring(0, _strWhere.Length - 3);
        }
        return _strWhere;

    }


    #region IPageDescribe 成员

    public string Name
    {
        get { return "新增商品产地"; }
    }

    public string Describe
    {
        get { return ""; }
    }

    public string ParentName
    {
        get { return "商品维护"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCheckGoods);
            return _AccountType;
        }
    }
    #endregion
}
